<?php
/* 
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/**
 * Description of EnviarMail
 *
 * @author fer
 *
 * Usa la clase Mail del framework PEAR
 *
 * Hay que instalar:
 *
 *  php-pear (5.2.6.dfsg.1-3ubuntu4.4)
 *  php-mail (1.1.14-1+lenny1build0.9.04.1)
 *  php-net-smtp (1.3.1-1)
 *  php-net-socket (1.0.9-1ubuntu1)
 *
 */



require_once "Mail.php";


class EnviarMail {
    //put your code here

    function enviar(){
        $from = "Sandra Sender <sender@example.com>";
        $to = "Ramona Recipient <recipient@example.com>";
        $subject = "Hi!";
        $body = "Hi,\n\nHow are you?";

        $host = "mail.example.com";
        $username = "smtp_username";
        $password = "smtp_password";

        $headers = array ('From' => $from,
          'To' => $to,
          'Subject' => $subject);
        $smtp = Mail::factory('smtp',
          array ('host' => $host,
            'auth' => true,
            'username' => $username,
            'password' => $password));

        $mail = $smtp->send($to, $headers, $body);

        if (PEAR::isError($mail)) {
            echo("<p>" . $mail->getMessage() . "</p>");
        } else {
            echo("<p>Message successfully sent!</p>");
        }
    }

}
?>
